package com.bigShen.spring.official;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;

/**
 * @author : lei.shen
 * @date : 2019/1/15
 */
public class XmlBeanFactoryDemo {

    public static void main(String[] args) {

        /**
         * 定位  载入  注册
         * {@link org.springframework.beans.factory.xml.XmlBeanFactory}
         * {@link org.springframework.context.support.ClassPathXmlApplicationContext
         */

        // 资源定位, 获取bean配置
        ClassPathResource resource = new ClassPathResource("src/applicationContext.xml");
        // 创建bean工厂
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        // 创建资源读取器,解析载入bean
        // 并且将beanFactory当做参数传入,以便将bean载入完后回调beanFactory的方向注册进beanFactory
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
        // 解析资源并将bean载入和注册进IOC容器
        reader.loadBeanDefinitions(resource);


        XmlBeanDefinitionReader reader1 = new XmlBeanDefinitionReader(new DefaultListableBeanFactory());
        reader1.loadBeanDefinitions(new ClassPathResource("application.xml"));




    }

}
